package com.module.ble.ui.bindGuide

import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.common.app.base.AppActivity
import com.common.app.core.RouterHub
import com.common.app.helper.RouterHelper
import com.common.app.utls.HeadTitleUtils
import com.common.base.app.activity.BaseNavActivity
import com.common.base.app.extras.setOnClickListener
import com.common.base.app.viewmodel.BaseViewModel
import com.common.base.utils.StatusBarUtils
import com.module.ble.databinding.BleActivityRingBindGuideBinding

/**
 * 作者：sosou
 * <p>
 * 版本：1.0
 * <p>
 * 创建日期：2024/11/15
 * <p>
 * 描述：绑定引导页面
 * <p>
 * 修订历史：
 */
@Route(path = RouterHub.ROUTER_BIND_GUIDE)
class BindGuideActivity : BaseNavActivity<BleActivityRingBindGuideBinding>(),
    View.OnClickListener {

    override fun getViewContentBinding() = BleActivityRingBindGuideBinding.inflate(layoutInflater)

    override fun getPlaceholderView() = mViewBinding.mPlaceholderView

    override fun isShowToolBar(): Boolean = false
    override fun isStatusBarTranslate(): Boolean = true

    override fun initViews() {
        super.initViews()
        StatusBarUtils.setStatusBarHeight(mViewContentBinding.statusView)
        StatusBarUtils.setStatusBarForegroundColor(this, true)

        val headTitleUtils = HeadTitleUtils(this)
        headTitleUtils.setTitle("")
        headTitleUtils.setLineStyle(10)
    }

    override fun initEvents() {
        super.initEvents()
        mViewContentBinding.tvBing.setOnClickListener(onClick = this)
    }

    override fun lazyInitData() {
        super.lazyInitData()
    }

    override fun onClick(v: View?) {
        RouterHelper.navigation(RouterHub.ROUTER_BLE_SCAN_DEVICE)
    }

    override fun onStart() {
        playAnimation()
        super.onStart()
    }

    override fun onStop() {
        stopAnimation()
        super.onStop()
    }
    override fun onDestroy() {
        stopAnimation()
        super.onDestroy()
    }

    fun playAnimation(){
        mViewContentBinding.bleAnimation.playAnimation()
    }

    fun stopAnimation(){
        mViewContentBinding.bleAnimation.pauseAnimation()
        mViewContentBinding.bleAnimation.frame = 0// 恢复到第一帧
        mViewContentBinding.bleAnimation.cancelAnimation()
    }
}